<?php

namespace Bean\Flow\PostsFlow;

class Link extends \Bean\Flow\GenericFlow\Link {

	private $_data;
	private $_link;
	private $_post;

	public function __construct( $data ) {
		parent::__construct();
		$this->_data = $data;
	}

	public function getLinkId() {
		return $this->_data['link_id'];
	}
	
	public function getDataLinkId() {
		return $this->_data['data_link_id'];
	}
	
	public function getLink() {
		if( $this->_link === null ) {
			$this->_link = \Bean\Db\Link::get( $this->getDataLinkId() );
		}
		return $this->_link;
	}
	
	public function getTitle() {
		return $this->getLink()->getTitle();
	}
	
	public function getDescription() {
		return $this->getLink()->getDescription();
	}
	
	public function getUrl() {
		return $this->getLink()->getUrl();
	}
	
	public function getSiteName() {
		return $this->getLink()->getSiteName();
	}
	
	public function getImage() {
		return $this->getLink()->getImage();
	}
	
	public function getUser() {
		return $this->getLink()->getUser();
	}

	public function getPostId() {
		return $this->_post['post_id'];
	}
	
	public function delete() {
		$this->getLink()->delete();
	}
	
	public function getPost() {
		if( $this->_post === null ) {
			$this->_post = \Bean\Post::get( $this->getPostId() );
		}
		return $this->_post;
	}
	
	public function getItem() {
		return $this->getPost();
	}
}
